using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;

public partial class Professionals : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        SqlConnection conn = new SqlConnection("data source=132.170.203.20;Initial Catalog=CET_4584;User ID=student;Password=password12");
        SqlDataReader rdr;
        SqlCommand cmd;

        String sqlPageId = "";
        pageNavigationLabel.Text = "";
        pageSubtitleLabel.Text = "";
        pageDescriptionLabel.Text = "";
        conn.Open();
        cmd = new SqlCommand("SELECT * FROM [pages] where CMSPage = 0 and Active = 1", conn);
        rdr = cmd.ExecuteReader();
        while (rdr.Read())
        {
            if (rdr["url"].ToString() == "Professionals.aspx")
            {
                sqlPageId = rdr["id"].ToString();
                pageSubtitleLabel.Text = rdr["subtitle"].ToString();
                pageDescriptionLabel.Text = rdr["description"].ToString();
            }
            pageNavigationLabel.Text += "<li><a href = '" + rdr["url"] + "'>" + rdr["title"] + "</a></li>";
        }
        conn.Close();

        infoLinksLabel.Text = "";
        conn.Open();
        cmd = new SqlCommand("SELECT * FROM [link_lists] WHERE page_id = " + sqlPageId + " AND link_type = 'info' and Active = 1", conn);
        rdr = cmd.ExecuteReader();
        while (rdr.Read())
        {
            infoLinksLabel.Text += "<h5><a href = '" + rdr["link_url"] + "'>" + rdr["link_text"] + "</a></h5>";
        }
        conn.Close();

        moreLinksLabel.Text = "";
        conn.Open();
        cmd = new SqlCommand("SELECT * FROM [link_lists] WHERE page_id = " + sqlPageId + " AND link_type = 'more' and Active = 1", conn);
        rdr = cmd.ExecuteReader();
        while (rdr.Read())
        {
            moreLinksLabel.Text += "<h5><a href = '" + rdr["link_url"] + "'>" + rdr["link_text"] + "</a></h5>";
        }
        conn.Close();

        quickLinksLabel.Text = "";
        conn.Open();
        cmd = new SqlCommand("SELECT * FROM [link_lists] WHERE page_id = " + sqlPageId + " AND link_type = 'quick' and Active = 1", conn);
        rdr = cmd.ExecuteReader();
        while (rdr.Read())
        {
            quickLinksLabel.Text += "<li><a href = '" + rdr["link_url"] + "'>" + rdr["link_text"] + "</a></li>";
        }
        conn.Close();
    }
}
